<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>核销奖品</title>
</head>
<style>
.reward_box{
	width:80%;
	height:auto;
	margin-left:10%;
	margin-top:100px;
	border:1px solid #eee;
	border-radius:5px;
	box-shadow: 0px 0px 15px #888888;
}
.r_title{
	width:100%;
	height:40px;
	text-align:center;
	line-height:40px;
	border-bottom:1px solid #eee;
	font-weight: 600;
}
.r_content{
	width:100%;
	height:34px;
	line-height:34px;
	border-bottom:1px solid #eee;
	display: -webkit-flex;
	display: flex;
}
.r_content .r_left{
	text-align: center;
	-webkit-flex: 1;
    flex: 1;
}
.r_content .r_right{
	-webkit-flex: 2;
    flex: 2;
    overflow: hidden;
}
.r_footer{
	width:100%;
	height:40px;
	text-align:center;
	line-height:40px;
	font-weight: 600;
	background:{$color};
	color:#fff;
	border-bottom-left-radius: 5px;
	border-bottom-right-radius: 5px;
}
.check_no {
    border: none;
}
</style>
<body>

<div class="reward_box">
	<div class="r_title">{$reward_info['title']}</div>
	<div class="r_content">
		<span class="r_left">获奖者：</span>
		<span class="r_right">{$mem['nickname']}</span>
	</div>
	<div class="r_content">
		<span class="r_left">商&nbsp;家：</span>
		<span class="r_right">{$store['title']}</span>
	</div>
	<div class="r_content">
		<span class="r_left">活&nbsp;动：</span>
		<span class="r_right">{$active['title']}</span>
	</div>
	<div class="r_content">
		<span class="r_left">时&nbsp;间：</span>
		<span class="r_right">{php echo date('Y-m-d H:i',$reward['createtime'])}</span>
	</div>
	{if $reward['status']==1}
	<div class="r_content">
		<span class="r_left">状&nbsp;态：</span>
		<span class="r_right">待核销</span>
	</div>
	<div class="r_content">
		<span class="r_left">核销码：</span>
		<span class="r_right"><input class="check_no" id="check_no" placeholder="请输入核销码" /></span>
	</div>
	<div class="r_footer" onclick="goCheck();">核销</div>
	{elseif $reward['status']==2}
	<div class="r_content">
		<span class="r_left">状&nbsp;态：</span>
		<span class="r_right">已核销</span>
	</div>
	{else}
	<div class="r_content">
		<span class="r_left">状&nbsp;态：</span>
		<span class="r_right">已提交</span>
	</div>
	{/if}
</div>
<script src="{RES}js/jquery-3.2.1.min.js"></script>
{template 'alert'}
<script>
var submit = false;
function goCheck(){
	if(submit) return false;
	if(!confirm('确认核销该奖品吗？')) return false;
	submit = true;
	var check_no = $('#check_no').val();
	if(!check_no){
		ALERT('请输入核销码');
		submit = false;
		return false;
	}
	$.ajax({
		url:"{php echo $this->createMobileUrl('check',array('id'=>$rid))}",
		data:{check_no:check_no},
		type:'post',
		success:function(dat){
			if(dat!=1){
				ALERT(dat);
				submit = false;
			}
			else ALERT('核销成功','知道了',function(){
				window.location.reload();
			});
		},
		error:function(){
			submit = false;
			ALERT('网络错误，请稍后重试');
		}
	});
}

</script>

</body>
</html>